package com.qlslylq.ad.sdk.model.rsp;

import com.qlslylq.ad.sdk.constant.AppConst;
import com.qlslylq.ad.sdk.enums.AdType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 广告位策略配置<br/>
 */
public class AdPlaceWebVO implements Serializable {

    private String adPlaceId;

    private String adTypeSign;

    private float parallelRequestTime;

    private float requestTime;

    private int requestNum;

    private String requestType;

    private List<List<AdPlaceWebConfigureVO>> configures;

    public String getAdPlaceId() {
        return adPlaceId;
    }

    public void setAdPlaceId(String adPlaceId) {
        this.adPlaceId = adPlaceId;
    }

    public String getAdTypeSign() {
        return adTypeSign;
    }

    public void setAdTypeSign(String adTypeSign) {
        this.adTypeSign = adTypeSign;
    }

    public float getParallelRequestTime() {
        return parallelRequestTime;
    }

    public void setParallelRequestTime(float parallelRequestTime) {
        this.parallelRequestTime = parallelRequestTime;
    }

    public float getRequestTime() {
        return requestTime;
    }

    public void setRequestTime(float requestTime) {
        this.requestTime = requestTime;
    }

    public int getRequestNum() {
        return requestNum;
    }

    public void setRequestNum(int requestNum) {
        this.requestNum = requestNum;
    }

    public String getRequestType() {
        return requestType;
    }

    public void setRequestType(String requestType) {
        this.requestType = requestType;
    }

    public List<List<AdPlaceWebConfigureVO>> getConfigures() {
        if (configures == null) {
            configures = new ArrayList<>();
        }
        return configures;
    }

    public void setConfigures(List<List<AdPlaceWebConfigureVO>> configures) {
        this.configures = configures;
    }

    /**
     * 数据加工<br/>
     */
    public void process() {
        for (int index = 0, size = getConfigures().size(); index < size; index++) {
            for (AdPlaceWebConfigureVO item : getConfigures().get(index)) {
                item.setAdType(AdType.getEnumByName(adTypeSign));
                item.setGroupIndex(index);
                //临时测试
//                item.setWeight(1);
            }
        }
        //临时模拟
        if (AppConst.openSecretLog) {
//            parallelRequestTime = 7f;
//            requestTime = 6f;
//            getConfigures().get(0).addAll(getConfigures().get(0));
//            getConfigures().get(0).get(1).setWeight(100);
        }
    }
}
